<?php

namespace App\Repositories;

use App\Exceptions\BasicException;
use Illuminate\Support\Facades\Hash;
use function Matrix\add;    //引入hash

class WinJackpotRepository {

    /**
     * 获取本期奖池列表
     * @param $type
     * @return bool
     */
    public function thisGiftList($type) {
        $thisGiftList = app('model_win_jackpot')->where('type',$type)->orderBy('id', 'desc')->select('id','number','gift_id','ratio')->with('gift')->get()->toArray();
        return $thisGiftList;
    }

    /*
     * 新增钓鱼本期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     *
     * */
    public function addThisPrize($param) {
        $addThisPrize = app('model_win_jackpot')->create($param);
        if ($addThisPrize) return $addThisPrize;
        throw new BasicException(93040);
    }

    /*
     * 编辑钓鱼本期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function saveThisPrize($param) {
        $saveThisPrize = app('model_win_jackpot')->where('id', $param['id'])->update($param);
        if ($saveThisPrize!==false) return true;
        throw new BasicException(93041);
    }

    /*
     * 删除钓鱼本期奖池
     * @param $param
     * @return bool
     * @throws BasicException
     * */
    public function delThisPrize($param) {
        $delThisPrize = app('model_win_jackpot')->whereIn('id', $param)->delete();
        if ($delThisPrize) return $delThisPrize;
        throw new BasicException(93043);
    }
    /*
     * 一键修改礼物
     * @param $param
     *
     * */
    public function editAllGifts($param) {
        app('model_win_jackpot')->where('id', $param['id'])->update($param);
    }

}


?>